package com.rs.game.npc.others;

import com.rs.game.WorldTile;
import com.rs.game.npc.NPC;
import com.rs.game.player.Player;
import com.rs.game.player.controlers.StartTutorial;
import com.rs.utils.Utils;

@SuppressWarnings("serial")
public class TutorialGuide extends NPC {

	private Player target;
	private StartTutorial controler;
	private long createTime;

	public TutorialGuide(WorldTile tile, Player target, StartTutorial controler) {
		super(949, tile, -1, true, true);
		this.target = target;
		this.controler = controler;
		createTime = Utils.currentTimeMillis();
		faceNPC(target);
	}

	public void faceNPC(Player target) {
		target.faceEntity(this);
	}

	@Override
	public void processNPC() {
		if (target.hasFinished()
				|| createTime + 15000 < Utils.currentTimeMillis()
				|| controler == null)
			finish();
		faceEntity(target);
	}

	@Override
	public boolean withinDistance(Player tile, int distance) {
		return tile == target && super.withinDistance(tile, distance);
	}

}